package java8Up.stream.filter_map;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Fang Ruichuan
 * @date 2022-12-23 8:22
 */
public class PersonTest {
    public static void main(String[] args) {
        List<Person> persons = new LinkedList<>();
        for (int i = 0; i < 5; i++) {
            Person person = new Person();
            person.setAge(i);
            person.setName("姓名_" + i);
            persons.add(person);
        }
    }

    // 测试filter     类型不变
    private static void testFilter(List<Person> persons) {
        List<Person> collect = persons.stream().filter(e -> e.getAge().equals(1)).collect(Collectors.toList());
    }

    // 测试map        类型改变
    private static void testMap(List<Person> persons) {
        List<Integer> collect = persons.stream().map(Person::getAge).collect(Collectors.toList());
    }
}
